package br.uniriotec.pssgbd.trab.model.bo;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class PadraoBO{

	private String url="jdbc:postgresql://localhost:5432/amannda";
	
	private String user = "postgres";
	
	private String password = "admin";
	
	private String postgresqldriver = "org.postgresql.Driver";
	
	public boolean autoCommit = true;
	
	private Connection connection;
	
	public Connection criaConexao(Boolean autocommit)throws Exception{
		try{
			Class.forName(postgresqldriver);
		} catch (ClassNotFoundException e){
			throw e;
		}
		try{
			connection = DriverManager.getConnection(url, user, password);
			connection.setAutoCommit(autoCommit);
		}
		catch (SQLException e){
			throw e;
		}
		return connection;
	}
	
	public void fechaConexao() throws SQLException{
		try{
			connection.close();
		}
		catch (SQLException e){
			throw e;
		}
	}
	
	public PadraoBO(){
		
	}
	
}
